<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <div id="box1">1</div><br>
    <div id="box2">2</div><br>
    <div id="box3">3</div><br>
    <script>
        /*
            一个事件由什么东西组成
                - 事件源：触发谁的事件
                - 事件类型：触发什么事件
                - 事件处理函数：触发以后要做什么
        */
        const box1 = document.querySelector('#box1')
        const box2 = document.querySelector('#box2')
        const box3 = document.querySelector('#box3')

        box1.onclick = function(){
            console.log(1)
        }

        box2.addEventListener('click',()=>{
            console.log(2)
        })

        box3.attachEvent
    </script>
</body>
</html>